Telegram Group & Telegram Channel
Напишите логистическую регрессию

import numpy as np

class LogisticRegression:

def __init__(self, learning_rate=0.01, n_iters=1000):
self.learning_rate = learning_rate
self.n_iters = n_iters
self.weights = None
self.bias = None

def fit(self, X, y):
# initialize weights and bias to zeros
n_samples, n_features = X.shape
self.weights = np.zeros(n_features)
self.bias = 0

# gradient descent optimization
for i in range(self.n_iters):
# calculate predicted probabilities and cost
z = np.dot(X, self.weights) + self.bias
y_pred = self._sigmoid(z)
cost = (-1 / n_samples) * np.sum(y * np.log(y_pred) + (1 - y) * np.log(1 - y_pred))

# calculate gradients
dw = (1 / n_samples) * np.dot(X.T, (y_pred - y))
db = (1 / n_samples) * np.sum(y_pred - y)

# update weights and bias
self.weights -= self.learning_rate * dw
self.bias -= self.learning_rate * db

def predict(self, X):
# calculate predicted probabilities
z = np.dot(X, self.weights) + self.bias
y_pred = self._sigmoid(z)
# convert probabilities to binary predictions
return np.round(y_pred).astype(int)

def _sigmoid(self, z):
return 1 / (1 + np.exp(-z))


#python
#машинное_обучение



tg-me.com/ds_interview_lib/611
Create:
Last Update:

Напишите логистическую регрессию

import numpy as np

class LogisticRegression:

def __init__(self, learning_rate=0.01, n_iters=1000):
self.learning_rate = learning_rate
self.n_iters = n_iters
self.weights = None
self.bias = None

def fit(self, X, y):
# initialize weights and bias to zeros
n_samples, n_features = X.shape
self.weights = np.zeros(n_features)
self.bias = 0

# gradient descent optimization
for i in range(self.n_iters):
# calculate predicted probabilities and cost
z = np.dot(X, self.weights) + self.bias
y_pred = self._sigmoid(z)
cost = (-1 / n_samples) * np.sum(y * np.log(y_pred) + (1 - y) * np.log(1 - y_pred))

# calculate gradients
dw = (1 / n_samples) * np.dot(X.T, (y_pred - y))
db = (1 / n_samples) * np.sum(y_pred - y)

# update weights and bias
self.weights -= self.learning_rate * dw
self.bias -= self.learning_rate * db

def predict(self, X):
# calculate predicted probabilities
z = np.dot(X, self.weights) + self.bias
y_pred = self._sigmoid(z)
# convert probabilities to binary predictions
return np.round(y_pred).astype(int)

def _sigmoid(self, z):
return 1 / (1 + np.exp(-z))


#python
#машинное_обучение

BY Библиотека собеса по Data Science | вопросы с собеседований


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/ds_interview_lib/611

View MORE
Open in Telegram


Библиотека собеса по Data Science | вопросы с собеседований Telegram | DID YOU KNOW?

Date: |

Can I mute a Telegram group?

In recent times, Telegram has gained a lot of popularity because of the controversy over WhatsApp’s new privacy policy. In January 2021, Telegram was the most downloaded app worldwide and crossed 500 million monthly active users. And with so many active users on the app, people might get messages in bulk from a group or a channel that can be a little irritating. So to get rid of the same, you can mute groups, chats, and channels on Telegram just like WhatsApp. You can mute notifications for one hour, eight hours, or two days, or you can disable notifications forever.

Telegram announces Anonymous Admins

The cloud-based messaging platform is also adding Anonymous Group Admins feature. As per Telegram, this feature is being introduced for safer protests. As per the Telegram blog post, users can “Toggle Remain Anonymous in Admin rights to enable Batman mode. The anonymized admin will be hidden in the list of group members, and their messages in the chat will be signed with the group name, similar to channel posts.”

Библиотека собеса по Data Science | вопросы с собеседований from ru


Telegram Библиотека собеса по Data Science | вопросы с собеседований
FROM USA